<?php
/**
 * Created by 张彪.
 * User: 小马出行
 * Date: 2017/11/2
 * Time: 14:56
 */
namespace app\inter\model;
use think\Db;

class CarListModel extends InterBase
{

    public function addCarList($data)
    {
        return Db::table('inter_car_list')->insertGetId($data);
    }

    public function getCarList($map,$field='a.*',$flag=true,$order='a.car_id desc',$page=1,$limit=10,$config='')
    {
        $config = $config?:$this->config;
        return $flag ? Db::table('xm_car_info a')->join(['xm_driver_base'=>'b'],'b.driver_id=a.driver_id','LEFT')->join(['xm_driver_info'=>'c'],'c.driver_id = b.driver_id', 'LEFT')
            ->where($map)->field($field)->page($page,$limit)->order($order)->select()
            : Db::table('xm_car_info a')->join(['xm_driver_base'=>'b'],'b.driver_id=a.driver_id','LEFT')
                 ->join(['xm_driver_info'=>'c'],'c.driver_id = b.driver_id', 'LEFT')->where($map)->field($field)->find();
    }

    public function updateCarList($map,$data)
    {
        return Db::table('inter_car_list')->where($map)->update($data);
    }
}